package com.thinkfit.jy.fragment;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.common.lib.constant.Constants;
import com.common.lib.constant.EventBusEvent;
import com.common.lib.fragment.BaseFragment;
import com.common.lib.manager.DataManager;
import com.common.lib.mvp.contract.EmptyContract;
import com.common.lib.mvp.presenter.EmptyPresenter;
import com.thinkfit.jy.R;
import com.thinkfit.jy.utils.ThemeUtils;

import org.greenrobot.eventbus.EventBus;

import java.util.HashMap;

/**
 * 主题模式界面
 */
public class ThemeModeFragment extends BaseFragment<EmptyContract.Presenter> implements EmptyContract.View {


    public static ThemeModeFragment getInstance(int index) {
        Bundle bundle = new Bundle();
        bundle.putInt(Constants.BUNDLE_EXTRA, index);
//        bundle.putInt(Constants.BUNDLE_EXTRA_2, type);
        ThemeModeFragment fragment = new ThemeModeFragment();
        fragment.setArguments(bundle);
        return fragment;
    }



    @Override
    protected int getLayoutId() {
        return R.layout.fragment_theme_mode;
    }

    @Override
    protected void initView(@NonNull View view, @Nullable Bundle savedInstanceState) {
        setViewsOnClickListener(R.id.ll_main,R.id.ll_scenery,R.id.ll_earth,R.id.ll_starry_sky);


    }



    @Override
    public void onResume() {
        super.onResume();

    }

    @Override
    public void onStop() {
        super.onStop();
    }


    @NonNull
    @Override
    protected EmptyContract.Presenter onCreatePresenter() {
        return new EmptyPresenter(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ll_main:
                DataManager.Companion.getInstance().saveMainTheme(ThemeUtils.THEME_MAIN);
                HashMap<String, Object> map = new HashMap<>();
                map.put(EventBusEvent.TO_HOME_ACTIVITY,"");
                EventBus.getDefault().post(map);
                break;
            case R.id.ll_scenery:
                DataManager.Companion.getInstance().saveMainTheme(ThemeUtils.THEME_SCENERY);
                map = new HashMap<>();
                map.put(EventBusEvent.TO_HOME_ACTIVITY,"");
                EventBus.getDefault().post(map);
                break;
            case R.id.ll_earth:
                DataManager.Companion.getInstance().saveMainTheme(ThemeUtils.THEME_EARTH);
                map = new HashMap<>();
                map.put(EventBusEvent.TO_HOME_ACTIVITY,"");
                EventBus.getDefault().post(map);
                break;
            case R.id.ll_starry_sky:
                DataManager.Companion.getInstance().saveMainTheme(ThemeUtils.THEME_STARRY_SKY);
                map = new HashMap<>();
                map.put(EventBusEvent.TO_HOME_ACTIVITY,"");
                EventBus.getDefault().post(map);
                break;

        }
    }



}
